/**
 *调用触发任务方法
 * @package
 */
export const dispatchAppTask = (data: any) => {
  const event = new CustomEvent("appTask", {
    detail: data,
    bubbles: true, // 事件是否冒泡
    cancelable: true, // 事件是否可以取消
  });
  window.dispatchEvent(event);
};

export const batchGetSourceUrls = (source: any, keys: string[]) => {
  return keys
    .map((key) => {
      const val = source[key];
      if (val) {
        return val.split(";");
      }
    })
    .flat()
    .filter((e) => !!e)
    .map((url) =>
      url.replace("https://eatnival.oss-cn-shenzhen.aliyuncs.com", "")
    );
};
